﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls">
    <Style TargetType="{x:Type Controls:MetroWindow}" x:Key="CleanWindowStyleKey">
        <Setter Property="ShowTitleBar" Value="False"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:MetroWindow}">
                    <ControlTemplate.Resources>
                        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
                    </ControlTemplate.Resources>
                    <Grid Background="{TemplateBinding Background}">
                        <AdornerDecorator>
                            <Controls:MetroContentControl IsTabStop="False" FocusVisualStyle="{x:Null}">
                                <Grid>
                                    <Grid.Background>
                                        <SolidColorBrush Color="{DynamicResource WhiteColor}"/>
                                    </Grid.Background>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid x:Name="PART_TitleBar" Panel.ZIndex="100" HorizontalAlignment="Stretch" Width="{TemplateBinding ActualWidth}"
                                          Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}">
                                        <Image
                                            Visibility="{TemplateBinding ShowIconOnTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}"
                                            Source="{TemplateBinding Icon}"
                                            RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="HighQuality" HorizontalAlignment="Left" VerticalAlignment="Top"/>


                                        <Label HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalAlignment="Top" 
                                               Content="{Binding Title, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" FontSize="14"/>

                                        <ContentPresenter 
                                            Content="{Binding WindowCommands, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" 
                                            x:Name="PART_WindowCommands"
                                            Panel.ZIndex="1"
								            VerticalAlignment="Top"
                                            HorizontalAlignment="Right" />
                                    </Grid>
                                    <ContentPresenter Grid.Row="1"/>

                                    <ItemsControl Grid.Row="0"
                                          Grid.RowSpan="2"
                                          Panel.ZIndex="2"
                                          KeyboardNavigation.TabNavigation="None"
                                          ItemsSource="{Binding Flyouts, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
                                          VerticalAlignment="Stretch">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <Grid TextElement.Foreground="{DynamicResource FlyoutWhiteBrush}" />
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                    </ItemsControl>
                                </Grid>
                            </Controls:MetroContentControl>
                        </AdornerDecorator>
                        <Border x:Name="PART_Border" Opacity="0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                                <Condition Property="WindowState" Value="Normal"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
                        </MultiTrigger>
                        <!--<Trigger Property="TitleCaps" Value="True">
                            <Setter TargetName="WindowTitleTextBlock" Property="Text" Value="{Binding Path=Title, Converter={StaticResource ToUpperConverter}, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>-->
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>